0 CpxTRS
↳1 TrsToWeightedTrsProof (BOTH BOUNDS(ID, ID), 0 ms)
↳2 CpxWeightedTrs
↳3 TypeInferenceProof (BOTH BOUNDS(ID, ID), 0 ms)
↳4 CpxTypedWeightedTrs
↳5 CompletionProof (UPPER BOUND(ID), 0 ms)
↳6 CpxTypedWeightedCompleteTrs
↳7 CpxTypedWeightedTrsToRntsProof (UPPER BOUND(ID), 0 ms)
↳8 CpxRNTS
↳9 CompleteCoflocoProof (⇔, 159 ms)
↳10 BOUNDS(1, 1)
terms(N) → cons(recip(sqr(N)))
sqr(0) → 0
sqr(s) → s
dbl(0) → 0
dbl(s) → s
add(0, X) → X
add(s, Y) → s
first(0, X) → nil
first(s, cons(Y)) → cons(Y)
terms(N) → cons(recip(sqr(N))) [1]
sqr(0) → 0 [1]
sqr(s) → s [1]
dbl(0) → 0 [1]
dbl(s) → s [1]
add(0, X) → X [1]
add(s, Y) → s [1]
first(0, X) → nil [1]
first(s, cons(Y)) → cons(Y) [1]
terms(N) → cons(recip(sqr(N))) [1]
sqr(0) → 0 [1]
sqr(s) → s [1]
dbl(0) → 0 [1]
dbl(s) → s [1]
add(0, X) → X [1]
add(s, Y) → s [1]
first(0, X) → nil [1]
first(s, cons(Y)) → cons(Y) [1]
terms :: 0:s → cons:nil cons :: recip → cons:nil recip :: 0:s → recip sqr :: 0:s → 0:s 0 :: 0:s s :: 0:s dbl :: 0:s → 0:s add :: 0:s → 0:s → 0:s first :: 0:s → cons:nil → cons:nil nil :: cons:nil |
first(v0, v1) → null_first [0]
null_first, const
Runtime Complexity Weighted TRS with Types. The TRS R consists of the following rules:
The TRS has the following type information:
Rewrite Strategy: INNERMOST |
0 => 0
s => 1
nil => 0
null_first => 0
const => 0
add(z, z') -{ 1 }→ X :|: z' = X, X >= 0, z = 0
add(z, z') -{ 1 }→ 1 :|: z' = Y, Y >= 0, z = 1
dbl(z) -{ 1 }→ 1 :|: z = 1
dbl(z) -{ 1 }→ 0 :|: z = 0
first(z, z') -{ 1 }→ 0 :|: z' = X, X >= 0, z = 0
first(z, z') -{ 0 }→ 0 :|: v0 >= 0, v1 >= 0, z = v0, z' = v1
first(z, z') -{ 1 }→ 1 + Y :|: Y >= 0, z = 1, z' = 1 + Y
sqr(z) -{ 1 }→ 1 :|: z = 1
sqr(z) -{ 1 }→ 0 :|: z = 0
terms(z) -{ 1 }→ 1 + (1 + sqr(N)) :|: z = N, N >= 0
eq(start(V, V1),0,[terms(V, Out)],[V >= 0]). eq(start(V, V1),0,[sqr(V, Out)],[V >= 0]). eq(start(V, V1),0,[dbl(V, Out)],[V >= 0]). eq(start(V, V1),0,[add(V, V1, Out)],[V >= 0,V1 >= 0]). eq(start(V, V1),0,[first(V, V1, Out)],[V >= 0,V1 >= 0]). eq(terms(V, Out),1,[sqr(N1, Ret11)],[Out = 2 + Ret11,V = N1,N1 >= 0]). eq(sqr(V, Out),1,[],[Out = 0,V = 0]). eq(sqr(V, Out),1,[],[Out = 1,V = 1]). eq(dbl(V, Out),1,[],[Out = 0,V = 0]). eq(dbl(V, Out),1,[],[Out = 1,V = 1]). eq(add(V, V1, Out),1,[],[Out = X1,V1 = X1,X1 >= 0,V = 0]). eq(add(V, V1, Out),1,[],[Out = 1,V1 = Y1,Y1 >= 0,V = 1]). eq(first(V, V1, Out),1,[],[Out = 0,V1 = X2,X2 >= 0,V = 0]). eq(first(V, V1, Out),1,[],[Out = 1 + Y2,Y2 >= 0,V = 1,V1 = 1 + Y2]). eq(first(V, V1, Out),0,[],[Out = 0,V2 >= 0,V3 >= 0,V = V2,V1 = V3]). input_output_vars(terms(V,Out),[V],[Out]). input_output_vars(sqr(V,Out),[V],[Out]). input_output_vars(dbl(V,Out),[V],[Out]). input_output_vars(add(V,V1,Out),[V,V1],[Out]). input_output_vars(first(V,V1,Out),[V,V1],[Out]). |
CoFloCo proof output:
Preprocessing Cost Relations
=====================================
#### Computed strongly connected components
0. non_recursive : [add/3]
1. non_recursive : [dbl/2]
2. non_recursive : [first/3]
3. non_recursive : [sqr/2]
4. non_recursive : [terms/2]
5. non_recursive : [start/2]
#### Obtained direct recursion through partial evaluation
0. SCC is partially evaluated into add/3
1. SCC is partially evaluated into dbl/2
2. SCC is partially evaluated into first/3
3. SCC is partially evaluated into sqr/2
4. SCC is completely evaluated into other SCCs
5. SCC is partially evaluated into start/2
Control-Flow Refinement of Cost Relations
=====================================
### Specialization of cost equations add/3
* CE 12 is refined into CE [16]
* CE 11 is refined into CE [17]
### Cost equations --> "Loop" of add/3
* CEs [16] --> Loop 10
* CEs [17] --> Loop 11
### Ranking functions of CR add(V,V1,Out)
#### Partial ranking functions of CR add(V,V1,Out)
### Specialization of cost equations dbl/2
* CE 10 is refined into CE [18]
* CE 9 is refined into CE [19]
### Cost equations --> "Loop" of dbl/2
* CEs [18] --> Loop 12
* CEs [19] --> Loop 13
### Ranking functions of CR dbl(V,Out)
#### Partial ranking functions of CR dbl(V,Out)
### Specialization of cost equations first/3
* CE 14 is refined into CE [20]
* CE 13 is refined into CE [21]
* CE 15 is refined into CE [22]
### Cost equations --> "Loop" of first/3
* CEs [20] --> Loop 14
* CEs [21,22] --> Loop 15
### Ranking functions of CR first(V,V1,Out)
#### Partial ranking functions of CR first(V,V1,Out)
### Specialization of cost equations sqr/2
* CE 8 is refined into CE [23]
* CE 7 is refined into CE [24]
### Cost equations --> "Loop" of sqr/2
* CEs [23] --> Loop 16
* CEs [24] --> Loop 17
### Ranking functions of CR sqr(V,Out)
#### Partial ranking functions of CR sqr(V,Out)
### Specialization of cost equations start/2
* CE 2 is refined into CE [25,26]
* CE 3 is refined into CE [27,28]
* CE 4 is refined into CE [29,30]
* CE 5 is refined into CE [31,32]
* CE 6 is refined into CE [33,34]
### Cost equations --> "Loop" of start/2
* CEs [34] --> Loop 18
* CEs [26,28,30,32,33] --> Loop 19
* CEs [25,27,29,31] --> Loop 20
### Ranking functions of CR start(V,V1)
#### Partial ranking functions of CR start(V,V1)
Computing Bounds
=====================================
#### Cost of chains of add(V,V1,Out):
* Chain [11]: 1
with precondition: [V=0,V1=Out,V1>=0]
* Chain [10]: 1
with precondition: [V=1,Out=1,V1>=0]
#### Cost of chains of dbl(V,Out):
* Chain [13]: 1
with precondition: [V=0,Out=0]
* Chain [12]: 1
with precondition: [V=1,Out=1]
#### Cost of chains of first(V,V1,Out):
* Chain [15]: 1
with precondition: [Out=0,V>=0,V1>=0]
* Chain [14]: 1
with precondition: [V=1,V1=Out,V1>=1]
#### Cost of chains of sqr(V,Out):
* Chain [17]: 1
with precondition: [V=0,Out=0]
* Chain [16]: 1
with precondition: [V=1,Out=1]
#### Cost of chains of start(V,V1):
* Chain [20]: 2
with precondition: [V=0]
* Chain [19]: 2
with precondition: [V=1]
* Chain [18]: 1
with precondition: [V>=0,V1>=0]
Closed-form bounds of start(V,V1):
-------------------------------------
* Chain [20] with precondition: [V=0]
- Upper bound: 2
- Complexity: constant
* Chain [19] with precondition: [V=1]
- Upper bound: 2
- Complexity: constant
* Chain [18] with precondition: [V>=0,V1>=0]
- Upper bound: 1
- Complexity: constant
### Maximum cost of start(V,V1): 2
Asymptotic class: constant
* Total analysis performed in 80 ms.